// router.js
// 通过传递过来到pathname，来进行不同的操作，如果是根目录，打印hello world
// 如果是/index 打印 pathname :/index
// 如果是其他 打印404
function route(pathname, response) {
  console.log('About to route a request for ' + pathname)
  response.writeHead(200, { 'Content-Type': 'text/plain' })
  if (pathname === '/') {
    response.write('Hello World')
    response.end()
  } else if (pathname === '/index') {
    response.write('pathname :/index')
    response.end()
  } else {
    response.write('404')
    response.end()
  }
}
exports.route = route